
package com.cptravel.adapter;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.core.controller.B5MBaseAdapter;
import com.core.util.B5MActivityHelper;
import com.core.util.B5MBitmapHelper;
import com.cptravel.R;
import com.cptravel.activity.order.BookJingQuActivity;
import com.cptravel.activity.order.BookJiuDianActivity;
import com.cptravel.bean.Xiangxi;

public class HotDetailAdapter extends B5MBaseAdapter<Xiangxi>
{
    public HotDetailAdapter(Activity activity, List<Xiangxi> mList)
    {
        super(activity, mList);
        // TODO Auto-generated constructor stub
    }

    @Override
    public View getView(int position , View convertView , ViewGroup parent , ViewHolder viewHolder)
    {
        // TODO Auto-generated method stub
        ImageView iv_logo = viewHolder.obtainView(convertView, R.id.iv_logo);
        TextView tv_title = viewHolder.obtainView(convertView, R.id.tv_title);
        TextView tv_room = viewHolder.obtainView(convertView, R.id.tv_roomType);
        TextView tv_ticket = viewHolder.obtainView(convertView, R.id.tv_ticketType);
        TextView tv_price = viewHolder.obtainView(convertView, R.id.tv_price);
        Button bt_order = viewHolder.obtainView(convertView, R.id.bt_order);
        final Xiangxi xiangxi = list.get(position);
        B5MBitmapHelper.displayDefaultNotPeopleRoundImage(xiangxi.thum_img, iv_logo);
        tv_title.setText(xiangxi.title);
        tv_room.setText(xiangxi.roomtype);
        tv_ticket.setText(xiangxi.ticketstype);
        tv_price.setText("￥" + xiangxi.price);
        bt_order.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                Bundle bundle = new Bundle();
                bundle.putSerializable("xiangxi", xiangxi);
                if ("1".equals(xiangxi.classid))//1酒店房间2景区
                {
                    B5MActivityHelper.startActivity(activity, BookJiuDianActivity.class, bundle);
                }
                else if ("2".equals(xiangxi.classid))
                {
                    B5MActivityHelper.startActivity(activity, BookJingQuActivity.class, bundle);
                }
            }
        });
        return convertView;
    }

    @Override
    public int itemLayoutRes()
    {
        // TODO Auto-generated method stub
        return R.layout.hot_detail_item;
    }
}
